# -*- coding: utf-8 -*-
"""
PBAR_MakeMarker.py

Created on Wed May 14 12:42:09 2014

@author: jkwong
"""

boxCorners = np.array([[ 270.64516129,  425.04231738],
       [ 287.41935484,  421.86397985],
       [ 273.22580645,  396.36020151],
       [ 291.29032258,  392.26700252],
       [ 275.80645161,  369.59697733],
       [ 293.87096774,  364.55919395],
       [ 278.38709677,  344.72292191],
       [ 300.32258065,  334.96221662],
       [ 279.67741935,  320.47858942],
       [ 297.74193548,  314.81108312],
       [ 282.25806452,  297.49370277],
       [ 301.61290323,  292.14105793],
       [ 284.83870968,  274.19395466],
       [ 301.61290323,  270.73047859],
       [ 772.58064516,  423.75314861],
       [ 790.64516129,  409.89924433],
       [ 771.29032258,  396.04534005],
       [ 795.80645161,  387.22921914],
       [ 770.        ,  368.96725441],
       [ 792.        ,  360.00000000],
	 [  768.70967742,   344.09319899],
       [  785.48387097,   332.12846348],
       [  767.41935484,   320.16372796],
       [  781.61290323,   310.40302267],
       [  766.12903226,   296.23425693],
       [  784.19354839,   290.56675063],
       [  766.12903226,   272.61964736],
       [  780.32258065,   264.11838791],
       [ 1353.22580645,   422.17884131],
       [ 1371.29032258,   414.62216625],
       [ 1354.51612903,   394.78589421],
       [ 1371.29032258,   389.11838791],
       [ 1351.93548387,   369.28211587],
       [ 1367.41935484,   363.29974811],
       [ 1353.22580645,   341.88916877],
       [ 1375.16129032,   335.90680101],
       [ 1351.93548387,   319.53400504],
       [ 1368.70967742,   313.55163728],
	 [ 1353.22580645,   296.86397985],
       [ 1364.83870968,   293.08564232],
       [ 1354.51612903,   274.50881612],
       [ 1372.58064516,   266.95214106],
       [ 1344.19354839,   256.56171285],
       [ 1355.80645161,   251.83879093],
       [ 1799.67741935,   421.23425693],
       [ 1820.32258065,   413.67758186],
       [ 1799.67741935,   392.89672544],
       [ 1816.4516129 ,   386.59949622],
       [ 1799.67741935,   367.3929471 ],
       [ 1811.29032258,   362.35516373],
       [ 1799.67741935,   342.51889169],
       [ 1812.58064516,   338.11083123],
       [ 1799.67741935,   319.21914358],
       [ 1826.77419355,   306.62468514],
       [ 1799.67741935,   296.86397985],
       [ 1815.16129032,   291.51133501],
       [ 1802.25806452,   274.82367758],
       [ 1819.03225806,   267.89672544],
       [ 1785.48387097,   258.45088161], 
	   [ 1800.96774193,   253.09823677]])

materialList = ['DU']*7 + ['Fe']*7 + ['W']*8 + ['Pb']*8

# left < right
# top < bottom
#'<shape type="rectangle"><color value="0xFFFF8800"/><locked value="0"/><rect left="1782" top="251" right="1830" bottom="425"/><text value="Pb"/><center x="1805" y="337" done="0" suspicious="0"/><left x="1721" y="337"/><right x="1889" y="337"/></shape>'
entryList =[]
for i in xrange(boxCorners.shape[0]/2):
    topLeftIndex = 2*i
    bottomRightIndex = 2*i + 1    
    left = boxCorners[topLeftIndex][0]
    right = boxCorners[bottomRightIndex][0]
    top = boxCorners[topLeftIndex][1]
    bottom = boxCorners[bottomRightIndex][1]

    centerX = np.int(np.round((left + right)/2))
    centerY = np.int(np.round((top + bottom)/2) )
    backgroundLeft = np.int(np.round(left - 60))
    backgroundRight = np.int(np.round(right + 60))

    entryList.append('<shape type="rectangle"><color value="0xFFFF8800"/><locked value="0"/><rect left="%d" top="%d" right="%d" bottom="%d"/><text value="%s"/><center x="%d" y="%d" done="0" suspicious="0"/><left x="%d" y="%d"/><right x="%d" y="%d"/></shape>' %(left, top, right, bottom, materialList[i], centerX, centerY, backgroundLeft, centerY, backgroundLeft, centerY))


